Delphi code for error handling

The GetError function is a Print Engine error message capture function. It accepts the Job Number as a parameter and then gets the Error Code and Error String. It then passes this back out as a formatted string.

Calls used
PEGetErrorCode
PEGetErrorText
PEGetHandleString
Code
uses CRDelphi;
function GetError(const JobIn: smallint): string;
var
  Code      : smallint;
  StrHandle : hWnd;
  Buffer    : PChar;
  Length    : smallint;
  Ret       : Bool;
begin
  {Get the Error code from the Crpe}
  Code := PEGetErrorCode(JobIn);
  {Get the error message handle}
  Ret := PEGetErrorText(JobIn, StrHandle, Length);
  Buffer := StrAlloc(Length);
  {Get the text from the text handle}
  Ret := PEGetHandleString(StrHandle, Buffer, Length);
  {Output the string}
  if Ret then
    Result := IntToStr(Code) + ' - ' + StrPas(Buffer)
  else
    Result := 'Unknown Error';
  StrDispose(Buffer);
end;


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com